home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 2002 January / PC Answers January 2002.7z / PC Answers January 2002.bin / graphics / freepixl / _SETUP.1 / Keyboard.pxl < prev    next >
Text File  |  2001-06-21  |  5KB  |  219 lines

  1. { PiXCL program to get keyboard input and draw it on the client area }
  2. Initialize:
  3.     UseCoordinates(PIXEL)
  4.     Title$ = "Keyboard Input Test"
  5.     WinGetActive(Current$)
  6.     WinTitle(Current$,Title$)
  7.     WinLocate(Title$,100,60,400,280,Res)
  8.  
  9.     InfoMenu(REMOVE)
  10.     WaitInput(100)
  11.     SetMenu("Exit!",Terminate,
  12.         ENDPOPUP,
  13.         "Start",Get_Input,
  14.         ENDPOPUP,
  15.         "Concept",Concept,
  16.         ENDPOPUP) 
  17.  
  18. Wait_for_Input:
  19.     WaitInput()
  20.  
  21. Concept:
  22.     MessageBox(OK,1,INFORMATION,
  23. "This sample application show how to create text entry
  24. dialogs in the client area of your PiXCL program. The 
  25. dialog area is written with an OPAQUE background so the
  26. text is highlighted. A carriage return is the programmed
  27. default delimiter character: it could just as easily be
  28. the TAB character.
  29.  
  30. Multiple text entry boxes can be programmed: Entered text
  31. is saved in variable Input$, which can then be copied to
  32. a 'permanent' variable, and Input$ reset to NULL, ready to
  33. process the next text input box. You can use the SetMouse()
  34. command to make each text input box active at your command.
  35.  
  36. Finally, the key list can be extended to any almost any 
  37. character on the keyboard, and can be assigned a character 
  38. from any installed font.",
  39.     "'Keyboard.pxl' Sample Application",Res)
  40.     Goto Wait_for_Input 
  41.  
  42. Terminate:
  43.     End    
  44.  
  45. Get_Input:
  46.     GoSub Define_Keys
  47.     Input$ = ""
  48.     UseBackGround(TRANSPARENT,255,255,255)
  49.     DrawBackGround
  50.     UsePen(SOLID,1,0,0,0)
  51.     UseBrush(SOLID,255,255,255)
  52.     DrawRectangle(15,30,260,55)
  53.     UseFont("Arial",7,11,BOLD,NOITALIC,NOUNDERLINE,0,0,0)
  54.     DrawText(20,18,"Enter the first line of characters")
  55.     Goto Wait_for_Input
  56.  
  57.  
  58. Get_Keys_A: {process the keystrokes}
  59.     Key$ = "A"
  60.     Goto Process
  61. Get_Keys_B:
  62.     Key$ = "B"
  63.     Goto Process
  64. Get_Keys_C:
  65.     Key$ = "C"
  66.     Goto Process
  67. Get_Keys_D:
  68.     Key$ = "D"
  69.     Goto Process
  70. Get_Keys_E:
  71.     Key$ = "E"
  72.     Goto Process
  73. Get_Keys_F:
  74.     Key$ = "F"
  75.     Goto Process
  76. Get_Keys_G:
  77.     Key$ = "G"
  78.     Goto Process
  79. Get_Keys_H:
  80.     Key$ = "H"
  81.     Goto Process
  82. Get_Keys_I:
  83.     Key$ = "I"
  84.     Goto Process
  85. Get_Keys_J:
  86.     Key$ = "J"
  87.     Goto Process
  88. Get_Keys_K:
  89.     Key$ = "K"
  90.     Goto Process
  91. Get_Keys_L:
  92.     Key$ = "L"
  93.     Goto Process
  94. Get_Keys_M:
  95.     Key$ = "M"
  96.     Goto Process
  97. Get_Keys_N:
  98.     Key$ = "N"
  99.     Goto Process
  100. Get_Keys_O:
  101.     Key$ = "O"
  102.     Goto Process
  103. Get_Keys_P:
  104.     Key$ = "P"
  105.     Goto Process
  106. Get_Keys_Q:
  107.     Key$ = "Q"
  108.     Goto Process
  109. Get_Keys_R:
  110.     Key$ = "R"
  111.     Goto Process
  112. Get_Keys_S:
  113.     Key$ = "S"
  114.     Goto Process
  115. Get_Keys_T:
  116.     Key$ = "T"
  117.     Goto Process
  118. Get_Keys_U:
  119.     Key$ = "U"
  120.     Goto Process
  121. Get_Keys_V:
  122.     Key$ = "V"
  123.     Goto Process
  124. Get_Keys_W:
  125.     Key$ = "W"
  126.     Goto Process
  127. Get_Keys_X:
  128.     Key$ = "X"
  129.     Goto Process
  130. Get_Keys_Y:
  131.     Key$ = "Y"
  132.     Goto Process
  133. Get_Keys_Z:
  134.     Key$ = "Z"
  135.     Goto Process
  136. Get_Keys_Slash:
  137.     Key$ = "\"
  138.     Goto Process
  139. Get_Keys_Stop:
  140.     Key$ = "."
  141.     Goto Process
  142. Get_Keys_Colon:
  143.     Key$ = ":"
  144.     Goto Process
  145. Get_Keys_SP:
  146.     Key$ = " "
  147. Process:
  148.     Input$ = Input$ + Key$
  149.     Len(Input$,Long)
  150.  
  151.     {Str(Long,Long$)
  152.     MessageBox(OK,1,INFORMATION,Long$,"DEBUG: Input$ length",Res) }
  153.  
  154.     If Long <= 24 Then Goto Process_1
  155.         MessageBox(OK,1,EXCLAMATION,
  156. "Input Length exceeds 24 characters. This is an 
  157. arbitrary number under your PiXCL script control.",
  158.         "WARNING: Input string too long",Res)
  159.         Long = 0
  160.         Goto Wait_For_Input
  161.     {endif}
  162. Process_1:
  163.     UseFont("System",9,15,BOLD,NOITALIC,NOUNDERLINE,0,0,0)
  164.     UseBackGround(OPAQUE,164,200,240)
  165.     DrawText(StartX,StartY,Input$)
  166.     Goto Wait_for_Input
  167.  
  168. Get_Keys_CR:
  169.     MessageBox(OK,1,EXCLAMATION,Input$,"String entered in edit region",Res)
  170.     Goto Wait_for_Input
  171.  
  172. Get_Keys_Del:
  173.     Len(Input$,Long) If Long >=1 Then Long = Long - 1
  174.     Left(Input$,Long,Input$)
  175.     UseBrush(SOLID,255,255,255)
  176.     DrawRectangle(15,30,260,55)
  177.     DrawText(StartX,StartY,Input$)
  178.     Goto Wait_for_Input
  179. {===========================================================================}
  180. Define_Keys: {subroutine}
  181.     StartX = 20  StartY = 33
  182.     SetKeyboard()
  183.     SetKeyboard("a",Get_Keys_A,"A",Get_Keys_A,
  184.             "b",Get_Keys_B,"B",Get_Keys_B,
  185.             "c",Get_Keys_C,"C",Get_Keys_C,
  186.             "d",Get_Keys_D,"D",Get_Keys_D,
  187.             "e",Get_Keys_E,"E",Get_Keys_E,
  188.             "f",Get_Keys_F,"E",Get_Keys_F,
  189.             "g",Get_Keys_G,"E",Get_Keys_G,
  190.             "h",Get_Keys_H,"E",Get_Keys_H,
  191.             "i",Get_Keys_I,"E",Get_Keys_I,
  192.             "j",Get_Keys_J,"E",Get_Keys_J,
  193.             "k",Get_Keys_K,"E",Get_Keys_K,
  194.             "l",Get_Keys_L,"E",Get_Keys_L,
  195.             "m",Get_Keys_M,"E",Get_Keys_M,
  196.             "n",Get_Keys_N,"E",Get_Keys_N,
  197.             "o",Get_Keys_O,"E",Get_Keys_O,
  198.             "p",Get_Keys_P,"E",Get_Keys_P,
  199.             "q",Get_Keys_Q,"E",Get_Keys_Q,
  200.             "r",Get_Keys_R,"E",Get_Keys_R,
  201.             "s",Get_Keys_S,"E",Get_Keys_S,
  202.             "t",Get_Keys_T,"E",Get_Keys_T,
  203.             "u",Get_Keys_U,"E",Get_Keys_U,
  204.             "v",Get_Keys_V,"E",Get_Keys_V,
  205.             "w",Get_Keys_W,"E",Get_Keys_W,
  206.             "x",Get_Keys_X,"E",Get_Keys_X,
  207.             "y",Get_Keys_Y,"E",Get_Keys_Y,
  208.             "z",Get_Keys_Z,"E",Get_Keys_Z,
  209.             " ",Get_Keys_SP,13,Get_Keys_CR,
  210.             "\",Get_Keys_Slash,".",Get_Keys_Stop,
  211.             ":",Get_Keys_Colon, 46,Get_Keys_Del, 
  212.             8,Get_Keys_Del)
  213.     {additional keys can be added here, as desired.}
  214.     Return
  215.  
  216. {===========================================================================}
  217. UnDefine_Keys: {subroutine}
  218.     SetKeyboard()
  219.     Return